package com.hzcc.hzccblog.module.controller;

import com.hzcc.hzccblog.common.Result;
import com.hzcc.hzccblog.module.entity.dto.AddArticle;
import com.hzcc.hzccblog.module.entity.dto.AddArticleDraft;
import com.hzcc.hzccblog.module.service.ArticleDraftService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 早睡蛋
 * @Date 2022/7/19 10:44:15
 * @Desc:
 */
@CrossOrigin
@Slf4j
@RestController
@RequestMapping("api/draft")
public class ArticleDraftController {

    @Value("${articleImages.dir}")
    private String articleImages;

    @Autowired
    private ArticleDraftService articleDraftService;


    /**
     * 添加文章到草稿
     * @param addArticle
     * @return
     */
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "添加成功", response = Result.class),
            @ApiResponse(code = 400, message = "添加失败", response = Result.class),
            @ApiResponse(code = 401, message = "id为空", response = Result.class),
    })
    @ApiOperation("添加文章到草稿")
    @PostMapping("/addArticleDraft")
    public Result addArticleDraft(@RequestBody AddArticleDraft addArticleDraft){
        return articleDraftService.addArticleDraft(addArticleDraft);
    }

}
